home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / gsdbloo.exe / DEMOU004.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-27  |  3KB  |  130 lines

  1. program DemoU004;
  2. {------------------------------------------------------------------------------
  3.                               DBase Index Manager
  4.                                Useless Examples
  5.                                  Demo Program
  6.  
  7.        Copyright (c)  Richard F. Griffin
  8.  
  9.        22 February 1992
  10.  
  11.        102 Molded Stone Pl
  12.        Warner Robins, GA  31088
  13.  
  14.        -------------------------------------------------------------
  15.        Unit to demonstrate multiple index processing.
  16.  
  17.        The DEMOU4.DBF file will be created by using the MakeTestData
  18.        procedure in GS_GENF.PAS.
  19.  
  20.        The IndexTo routine will be used to index on LASTNAME and
  21.        BIRTHDATE.
  22.  
  23.        The indexed file will be listed ascending.
  24.  
  25.        Additional Records will be added to test multiple index update.
  26.  
  27.        Finally, the file will be listed again in LASTNAME and BIRTHDATE
  28.        index sequence.  Note the use of SetIndexMaster to switch between
  29.        which index is the master.
  30.  
  31. -------------------------------------------------------------------------------}
  32. uses
  33.    CRT,
  34.    DOS,
  35.    printer,
  36.    GS_Strng,
  37.    GS_Date,
  38.    GS_dBFld,
  39.    GS_dBase,
  40.    GS_GenF;
  41. var
  42.    MyFile  : GS_dBFld_Objt;
  43.    s       : string;
  44.    li      : boolean;
  45.    i       : integer;
  46.    c       : char;
  47.    jd      : longint;
  48.    ms      : string[30];
  49. begin
  50.    GS_Date_Century := true;
  51.    ClrScr;
  52.  
  53.    writeln('Creating DemoU4.DBF');
  54.    MakeTestData('DemoU4', 50, false);
  55.    writeln('DemoU4.DBF Created');
  56.  
  57.    MyFile.Init('DemoU4');
  58.    MyFile.Open;
  59.    MyFile.IndexTo('DemoU4A','LASTNAME');
  60.    MyFile.IndexTo('DemoU4B','BIRTHDATE');
  61.    MyFile.Index('DemoU4A, DemoU4B');
  62.  
  63.    i := 0;
  64.    MyFile.GetRec(Top_Record);
  65.    while (not MyFile.File_EOF) do
  66.    begin
  67.       inc(i);
  68.       if (i mod 23) = 0 then
  69.       begin
  70.          write('Press any key to continue.');
  71.          c := ReadKey;
  72.          writeln;
  73.       end;
  74.       writeln(MyFile.RecNumber:8,'   ',MyFile.FieldGet('LASTNAME'),i:6);
  75.       MyFile.GetRec(Next_Record);
  76.    end;
  77.  
  78.    writeln('End of File, Now for More Records...');
  79.    writeln('Press any key to continue.');
  80.    c := ReadKey;
  81.  
  82.    writeln('Adding DemoU4.DBF Records');
  83.    AddTestData(@MyFile, 50);
  84.    writeln('DemoU4.DBF Records Added');
  85.  
  86.               {save index structures to ascii files}
  87.  
  88.    MyFile.dbfNdxTbl[1]^.KeyList('list1.txt');
  89.    MyFile.dbfNdxTbl[2]^.KeyList('list2.txt');
  90.  
  91.    i := 0;
  92.    MyFile.GetRec(Top_Record);
  93.    while (not MyFile.File_EOF) do
  94.    begin
  95.       inc(i);
  96.       if (i mod 23) = 0 then
  97.       begin
  98.          write('Press any key to continue.');
  99.          c := ReadKey;
  100.          writeln;
  101.       end;
  102.       writeln(MyFile.RecNumber:8,'   ',MyFile.FieldGet('LASTNAME'),i:6);
  103.       MyFile.GetRec(Next_Record);
  104.    end;
  105.  
  106.    writeln('End of File, Now to check date sequence...');
  107.    writeln('Press any key to continue.');
  108.    c := ReadKey;
  109.  
  110.    MyFile.SetIndexMaster(2);
  111.  
  112.    i := 0;
  113.    MyFile.GetRec(Top_Record);
  114.    while (not MyFile.File_EOF) do
  115.    begin
  116.       inc(i);
  117.       if (i mod 23) = 0 then
  118.       begin
  119.          write('Press any key to continue.');
  120.          c := ReadKey;
  121.          writeln;
  122.       end;
  123.       writeln(MyFile.RecNumber:8,'   ',
  124.               GS_Date_View(MyFile.DateGet('BIRTHDATE')),i:6);
  125.       MyFile.GetRec(Next_Record);
  126.    end;
  127.  
  128.    MyFile.Close;
  129. end.
  130.